/*****************************************************************************
*
*  PROJECT:     SlipStream
*               (KeyBinds)
*  LICENSE:     GNU General Public License v3 - http://www.gnu.org/licenses/gpl.html

*  DEVELOPERS:  Philip Farquharson	<B00137077@studentmail.uws.ac.uk>
*				John Gray			<B00145524@studentmail.uws.ac.uk>		
*				Zohaib Bhatti		<B00104280@studentmail.uws.ac.uk>
*				Euan Hislop			<B00138636@studentmail.uws.ac.uk>
*
*****************************************************************************/
#include "CKeyBind.h"

// Constructor, takes a void function, a key and bind type (see header)
CKeyBind::CKeyBind ( KeybindCallback CallBack, eKey key, eBindType bindType )
{
	m_CallBack = CallBack; // void callback function
	m_key = key; // keyboard key
	m_bindType = bindType; // bind type
	m_ms = 0; // time in MS, currently 0
}

// Destructor
CKeyBind::~CKeyBind ( void )
{
	// nothing to be freed
}

// Calls the void callback function (Internal use only)
void CKeyBind::Trigger ( void )
{
	m_CallBack (  ); // call the void function
}

// Proc - calls the function and updates our timer
void CKeyBind::Proc ( void )
{
	if ( m_bindType == CKeyBind::BIND_TOGGLE ) // if we are using the timer
		m_ms = clock ( ); // then update the milliseconds timer to current time in ms

	this->Trigger ( ); // call our callback function
}